package org.sloth.core.remote
{
	import org.sloth.core.IData;
	import org.sloth.core.IUID;
	import org.sloth.core.StringUtil;
	
	/**
	 * 远程访问 <code>RemoteMgr</code> 关联的请求任务
	 */	
	public class RemoteVO implements IUID, IData
	{
//============================================================================
//PROPERTY
//============================================================================
		private var _uid:String;
		private var _funcName:String;
		private var _parameters:Array;
		private var _destination:String;
		private var _endpoint:String;
		private var _completeCB:Function;
		private var _errorCB:Function;
		private var _data:*;
		private var _content:*;
//============================================================================
//CONSTRUCTOR
//============================================================================
		public function RemoteVO(
			funcName:String, parameters:Array, 
			destination:String, endpoint:String, 
			completeCB:Function, errorCB:Function, data:*)
		{
			_uid = StringUtil.createUID();
			
			_funcName = funcName;
			_parameters = parameters;
			_destination = destination;
			_endpoint = endpoint;
			_completeCB = completeCB;
			_errorCB = errorCB;
			_data = data;
			
		}
//============================================================================
//GETTER/SETTER
//============================================================================
		
		public function get uid():String
		{
			return _uid;
		}
		
		public function set uid(value:String):void
		{
			_uid = value;
		}

		/**
		 * 需要要调用的远程服务函数名
		 */
		public function get funcName():String
		{
			return _funcName;
		}

		/**
		 * 远程服务函数参数队列（参数在数组中的顺序与远程服务函数要求的参数顺序一致）
		 */
		public function get parameters():Array
		{
			return _parameters;
		}

		/**
		 * 服务的目标。该值应与 services-config.xml 文件中的目标条目匹配。
		 */
		public function get destination():String
		{
			return _destination;
		}

		/**
		 * 服务器地址，比如 <code>http://127.0.0.1:8080/project/messagebroker/amf</code>
		 */
		public function get endpoint():String
		{
			return _endpoint;
		}

		/**
		 * 请求完成后回调，参数类型为 <code>RemoteVO</code>
		 */
		public function get completeCB():Function
		{
			return _completeCB;
		}

		/**
		 * 请求失败后回调，参数类型为 <code>RemoteVO</code>
		 */
		public function get errorCB():Function
		{
			return _errorCB;
		}

		/**
		 * 请求前后需要传递的数据
		 */
		public function get data():*
		{
			return _data;
		}
		
		public function set data(value:*):void
		{
			_data = value;
		}

		/**
		 * 请求结果实例。请求成功时，为服务器返回的数据；请求出错时，为出错信息。
		 */
		public function get content():*
		{
			return _content;
		}

		/**
		 * @private
		 */
		public function set content(value:*):void
		{
			_content = value;
		}


	}
}